package com.atguigu.gmall.common.constant;

/**
 * Redis常量配置类
 * set name admin
 *
 * #魔法值
 * Constant {
 *     //登录的用户
 *     public static final String LOGIN_USER = "aaaa";
 *
 * }
 *
 *  setkey(){ redis.set(Constant.LOGIN_USER,"xxxxx") }
 *
 *
 *  getkey(){ redis.get(Constant.LOGIN_USER) }
 */
public class RedisConst {

    // sku:50:info
    public static final String SKUKEY_PREFIX = "sku:";
    public static final String SKUKEY_SUFFIX = ":info";
    //单位：秒
    public static final long SKUKEY_TIMEOUT = 24 * 60 * 60;
    // 定义变量，记录空对象的缓存过期时间
    public static final long SKUKEY_TEMPORARY_TIMEOUT = 10 * 60;

    //单位：秒 尝试获取锁的最大等待时间
    public static final long SKULOCK_EXPIRE_PX1 = 1;
    //单位：秒 锁的持有时间
    public static final long SKULOCK_EXPIRE_PX2 = 1;
    public static final String SKULOCK_SUFFIX = ":lock";



    // user:7:cart
    public static final String USER_KEY_PREFIX = "user:";
    public static final String CART_PREFIX = "cart:info:";
    public static final String CART_TEMP_PREFIX = "cart:temp:";
    public static final long TEMP_CART_EXPIRE = 60 * 60 * 24 * 365; //临时购物车的过期时间
    //登录用户购物车 不过期


    //用户登录
    //user:login:18
    public static final String USER_LOGIN_KEY_PREFIX = "user:login:";
    //    public static final String userinfoKey_suffix = ":info";
    public static final int USERKEY_TIMEOUT = 60 * 60 * 24 * 7;
    //防重令牌
    public static final String USER_UNREPEAT_TOKEN = "user:token:"; //USER_UNREPEAT_TOKEN + 用户id
    public static final long USER_UNREPEAT_TOKEN_TTL = 60 * 10; //防重令牌有效时间
    //秒杀商品前缀
    public static final String SECKILL_GOODS = "seckill:goods";
    public static final String SECKILL_ORDERS = "seckill:orders";
    public static final String SECKILL_ORDERS_USERS = "seckill:orders:users";
    public static final String SECKILL_STOCK_PREFIX = "seckill:stock:";
    public static final String SECKILL_USER = "seckill:user:";
    //用户锁定时间 单位：秒
    public static final int SECKILL__TIMEOUT = 60 * 60 * 1;


}
